package com.app.asktom.component;

import com.app.asktom.MainActivity;

import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;


public class NetworkHelper {
	public static NetworkHelper getInstance() {
		return NetworkHolder.INSTANCE;
	}
	
    private static class NetworkHolder { 
        public static final NetworkHelper INSTANCE = new NetworkHelper();
    }
    
	public boolean isNetworkAvailable(MainActivity activity) {
	    ConnectivityManager connectivityManager 
	          = (ConnectivityManager) activity.getSystemService(Context.CONNECTIVITY_SERVICE);
	    NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
	    return activeNetworkInfo != null && activeNetworkInfo.isConnected();
	}	
	
	public void showNetworkSettings(MainActivity activity) {
		activity.startActivity(new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS));
	}
    
}
